<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>文章列表--layui后台管理模板 2.0</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		<link rel="stylesheet" href="../../layui/css/layui.css" media="all" />
		<link rel="stylesheet" href="../../css/public.css" media="all" />
	</head>

	<body class="childrenBody">
		<form class="layui-form">
			<div class="layui-form-item layui-row layui-col-xs12">
				<label class="layui-form-label">充值时间</label>
				<div class="layui-input-block">
					<input type="text" name="invest_addTime" class="layui-input invest_addTime" disabled id="invest_addTime" lay-filter="invest_addTime" lay-verify="required" />
				</div>
			</div>
			<div class="layui-form-item layui-row layui-col-xs12">
				<label class="layui-form-label">充值平台</label>
				<div class="layui-input-block">
					<input type="text" name="invest_type" class="layui-input invest_type" disabled id="invest_type" lay-filter="invest_type" lay-verify="required" />
				</div>
			</div>
			<div class="layui-form-item layui-row layui-col-xs12">
				<label class="layui-form-label">充值账号</label>
				<div class="layui-input-block">
					<input type="text" name="invest_num" class="layui-input invest_num" disabled id="invest_num" lay-filter="invest_num" lay-verify="required" />
				</div>
			</div>
			<div class="layui-form-item layui-row layui-col-xs12">
				<label class="layui-form-label">充值金额</label>
				<div class="layui-input-block">
					<input id="invest_name" type="hidden" name="invest_name" />
					<input id="user_name" type="hidden" name="user_name" />
					<input id="invest_id" type="hidden" name="invest_id" />
					<input type="number" name="invest_money" class="layui-input invest_money" disabled lay-verify="required" placeholder="">
				</div>
			</div>
			<div class="layui-form-item layui-row layui-col-xs12">
				<label class="layui-form-label">充值截图</label>
				<div class="layui-input-block">
					<img class="layui-upload-img" width="70%" id="picture">
				</div>
			</div>
			<div class="layui-form-item layui-row layui-col-xs12">
				<hr class="layui-bg-green" />
			</div>
			<div class="layui-form-item layui-row layui-col-xs12">
				<label class="layui-form-label">是否通过</label>
				<div class="layui-input-block invest_check">
					<input type="radio" name="invest_check" value="yes" title="通过" checked>
					<input type="radio" name="invest_check" value="no" title="不通过">
				</div>
			</div>
			<div class="layui-form-item layui-row layui-col-xs12">
				<label class="layui-form-label">审核说明</label>
				<div class="layui-input-block">
					<textarea class="layui-textarea check_desc" id="check_desc" name="check_desc"></textarea>
				</div>
			</div>
			<div class="layui-form-item layui-row layui-col-xs12">
				<div class="layui-input-block">
					<button id="addinvest" class="layui-btn layui-btn-sm" lay-submit="" lay-filter="addinvest">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-sm layui-btn-primary">取消</button>
				</div>
			</div>
		</form>
		<script type="text/javascript" src="../../layui/layui.js"></script>
		<script src="../../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="investAdd1.js"></script>
		<script type="text/javascript">
			layui.use(['form', 'layer', 'laydate', 'table', 'laytpl','upload'], function() {
				var form = layui.form,
					layer = parent.layer === undefined ? layui.layer : top.layer,
					$ = layui.jquery,
					laydate = layui.laydate,
					laytpl = layui.laytpl,
					table = layui.table,
					upload =layui.upload,
					laypage = layui.laypage;
					//$("#shili").show();
					$("#user_name").val(localStorage.login_name);
				console.log("1");
				var selectwangwang 	= "";
				var good_wangwang	= "";
				
				//获取下拉框的值
				$.ajax({
					type:"get",
					url:"http://127.0.0.1:88/index.php/invest/invest/select",
					data:"user="+localStorage.login_name,
					success:function(res){
						
						//$(".invest_wangwang").empty();
						var optionString="";
						$.each(res.data,function(key,value){
							$("#invest_type").append(new Option(value["count_type"]+" ("+value["count_num"]+")",value["count_id"]));
							optionString += '<option value="'+value["count_id"]+'">'+value["count_type"]+" ("+value["count_num"]+')</option>';
						});
						//console.log(optionString);
						layui.form.render('select');
						//$("#invest_wangwang").html(optionString);
					}
				});
				form.on("submit(addinvest)",function(data){
			        //弹出loading
			        //alert($("#file").val());
			        var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
			        var action 	= data.form.action;//表单提交URL地址
			        //var da		= data.field;
			        //console.log(data.field);
			        $.post("http://127.0.0.1:88/index.php/invest/invest/checkInvest",data.field,function(obj){
			        	
			        });
			        // 实际使用时的提交信息
			        /*$.post(action,{
			         	"invest_name"			: $(".invest_name").val,
			         	"invest_wangwang"		: $(".invest_wangwang").val,
			         	"invest_type"			: $(".invest_type").val,
			         	"user_name"			: localStorage.login_name,
			         	"invest_img_url"		: img_url
			        },function(res){
			        	
			        })*/
			        setTimeout(function(){
			            top.layer.close(index);
			            top.layer.msg("充值成功！");
			            layer.closeAll("iframe");
			            //刷新父页面
			            parent.location.reload();
			        },2000);
			        return false;
			    })
				/*var wangwang	= "";
				form.on('select(invest_wangwang)', function(data){
					wangwang	= data.value;
					if($(".invest_good_titles").val()){
						if(data.value!=good_wangwang){
							layer.msg("当前店铺联系方式与商品不一致，请重新选择");
						}
					}else{
						
					}
					
				});*/
				if ($(".invest_wangwang").attr("checked")==true) {
					console.log($(".invest_wangwang option:selected").text());
				}
				
				//普通图片上传
				 //先定义一个变量，用来存储回传的图片地址
				 var img_url = "";
				  var uploadInst = upload.render({
				    elem: '#test1'
				    ,url: 'http://127.0.0.1:88/index.php/invest/invest/investImg' //改成您自己的上传接口
				    ,before: function(obj){
				      //预读本地文件示例，不支持ie8
				      $("#shili").hide();
				      obj.preview(function(index, file, result){
				        $('#demo1').attr('src', result); //图片链接（base64）
				      });
				    }
				    ,done: function(res){
				      //如果上传失败
				      if(res.code == 200){
				        img_url = res.url;
				        $("#invest_img_url").val(img_url);
				        //console.log(img_url);
				      }else{
				      	return layer.msg('店铺截图上传失败');
				      }
				      //上传成功
				    }
				    /*,error: function(){
				      //演示失败状态，并实现重传
				      var demoText = $('#demoText');
				      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
				      demoText.find('.demo-reload').on('click', function(){
				        uploadInst.upload();
				      });
				    }*/
				  });	
				form.verify({
					invest_img_url:function(value){
						if(value == "") {
							return "请上传充值截图";
						}
					}
				});
			})
			
		</script>
	</body>

</html>